<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="解约合同编号" prop="sfContractNo">
        <el-input
          v-model="queryParams.sfContractNo"
          placeholder="请输入解约合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="小区名(使用楼盘名称)" prop="premiseName">
        <el-input
          v-model="queryParams.premiseName"
          placeholder="请输入小区名(使用楼盘名称)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="房东姓名" prop="ownerName">
        <el-input
          v-model="queryParams.ownerName"
          placeholder="请输入房东姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同录入时间，" prop="conInfoTime">
        <el-date-picker clearable
                        v-model="queryParams.conInfoTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择合同录入时间，">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="contractList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="解约合同编号" align="center" prop="sfContractNo" />
      <el-table-column label="小区名(使用楼盘名称)" align="center" prop="premiseName" />
      <el-table-column label="解约日期" align="center" prop="leaseStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.leaseStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核" align="center" prop="leaseEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.leaseEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结算金额" align="center" prop="signUserMobile" />
      <el-table-column label="录入日期，" align="center" prop="conInfoTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.conInfoTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="操作人" align="center" prop="signUserMobile" />-->
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import { breakList  } from "@/api/contract/contract";

  export default {
    name: "Contract",
    data() {
      return {
        // 表单校验
        rules: {
          sfContractNo: [
            { required: true, message: "合同编号不能为空", trigger: "blur" }
          ],
          businessId: [
            { required: true, message: "商户ID不能为空", trigger: "blur" }
          ],
          premiseName: [
            { required: true, message: "小区名(使用楼盘名称)不能为空", trigger: "blur" }
          ],
          houseId: [
            { required: true, message: "房产ID不能为空", trigger: "blur" }
          ],
          houseTitle: [
            { required: true, message: "房源标题不能为空", trigger: "blur" }
          ],
          ownerId: [
            { required: true, message: "房东ID不能为空", trigger: "blur" }
          ],
          ownerName: [
            { required: true, message: "房东姓名不能为空", trigger: "blur" }
          ],
          signUserName: [
            { required: true, message: "租户名称不能为空", trigger: "blur" }
          ],
          leaseStartTime: [
            { required: true, message: "租约期限开始时间不能为空", trigger: "blur" }
          ],
          leaseEndTime: [
            { required: true, message: "租约期限结束时间不能为空", trigger: "blur" }
          ],
          monthRent: [
            { required: true, message: "收房月租金不能为空", trigger: "blur" }
          ],
          depositType: [
            { required: true, message: "支付方式(押X付Y的X)不能为空", trigger: "change" }
          ],
          paymentType: [
            { required: true, message: "支付方式(押X付Y的Y）不能为空", trigger: "change" }
          ],
          operId: [
            { required: true, message: "合同录入人不能为空", trigger: "blur" }
          ],
          sfUserId: [
            { required: true, message: "收房人，不能为空", trigger: "blur" }
          ],
          sfUserName: [
            { required: true, message: "收房人姓名不能为空", trigger: "blur" }
          ],
          status: [
            { required: true, message: "合同状态不能为空", trigger: "blur" }
          ],
          xyStatus: [
            { required: true, message: "续约状态不能为空", trigger: "blur" }
          ],
          delFlg: [
            { required: true, message: "删除标识，0:未删除，1：删除不能为空", trigger: "blur" }
          ],
          createUserid: [
            { required: true, message: "创建用户ID不能为空", trigger: "blur" }
          ],
          createTime: [
            { required: true, message: "创建时间不能为空", trigger: "blur" }
          ],
          updateUserid: [
            { required: true, message: "更新用户ID不能为空", trigger: "blur" }
          ],
          updateTime: [
            { required: true, message: "更新时间不能为空", trigger: "blur" }
          ],
        },
        form:{},
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 【请填写功能名称】表格数据
        contractList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          sfContractNo: null,
          lastContractId: null,
          lastContractNo: null,
          businessId: null,
          premiseName: null,
          houseId: null,
          houseTitle: null,
          houseZsNo: null,
          cqAddress: null,
          ownerId: null,
          ownerName: null,
          ownerIdCard: null,
          ownerMobile: null,
          signUserName: null,
          signUserIdCard: null,
          signUserMobile: null,
          signUserEmergencyPhone: null,
          leaseStartTime: null,
          leaseEndTime: null,
          monthRent: null,
          depositMoney: null,
          depositType: null,
          paymentType: null,
          conSignTime: null,
          conInfoTime: null,
          conAudTime: null,
          operId: null,
          sfUserId: null,
          sfUserName: null,
          status: null,
          xyStatus: null,
          sfLoanFlg: null,
          reserve1: null,
          reserve2: null,
          reserve3: null,
          reserve4: null,
          reserve5: null,
          delFlg: null,
          createUserid: null,
          updateUserid: null,
          houseLeaseType: null
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询【请填写功能名称】列表 */
      getList() {
        this.loading = true;
        breakList(this.queryParams).then(response => {
          this.contractList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          sfContractNo: null,
          lastContractId: null,
          lastContractNo: null,
          businessId: null,
          premiseName: null,
          houseId: null,
          houseTitle: null,
          houseZsNo: null,
          cqAddress: null,
          ownerId: null,
          ownerName: null,
          ownerIdCard: null,
          ownerMobile: null,
          signUserName: null,
          signUserIdCard: null,
          signUserMobile: null,
          signUserEmergencyPhone: null,
          leaseStartTime: null,
          leaseEndTime: null,
          monthRent: null,
          depositMoney: null,
          depositType: null,
          paymentType: null,
          conSignTime: null,
          conInfoTime: null,
          conAudTime: null,
          operId: null,
          sfUserId: null,
          sfUserName: null,
          status: 0,
          xyStatus: 0,
          sfLoanFlg: null,
          remark: null,
          reserve1: null,
          reserve2: null,
          reserve3: null,
          reserve4: null,
          reserve5: null,
          delFlg: null,
          createUserid: null,
          createTime: null,
          updateUserid: null,
          updateTime: null,
          houseLeaseType: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      }
    }
  };
</script>
